package com.cm.demo1.service.impl;

import com.cm.demo1.entity.Drugs;
import com.cm.demo1.mapper.DrugsMapper;
import com.cm.demo1.service.DrugsService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 药物服务实现类
 */
@Service
public class DrugsServiceImpl implements DrugsService {

    @Resource
    private DrugsMapper drugsMapper;

    @Override
    public int addDrugs(Drugs drugs) {
        return drugsMapper.insert(drugs);
    }

    @Override
    public int deleteDrugs(Integer id) {
        return drugsMapper.deleteById(id);
    }

    @Override
    public int updateDrugs(Drugs drugs) {
        return drugsMapper.updateById(drugs);
    }

    @Override
    public Drugs getDrugsById(Integer id) {
        return drugsMapper.selectById(id);
    }

    @Override
    public List<Drugs> getAllDrugs() {
        return drugsMapper.selectAll();
    }
}